package com.chen.utils;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;

/**
 * ClassName: LambdaQueryWrapperX
 * Package: com.chen.utils
 * Description:
 *
 * @Author 陈俊辉
 * @Create 2024/4/11 17:39
 * @Version 1.0
 */
public class LambdaQueryWrapperX <T> extends LambdaQueryWrapper<T> {
    /**
     * 相等
     * @param field
     * @param value
     * @return
     */
    public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T,?> field, Object value){
        if(ObjectUtil.isNotEmpty(value)){
            return (LambdaQueryWrapperX<T>) super.eq(field,value);
        }
       return this;
    }

    /**
     * 小于等于
     * @param field
     * @param value
     * @return
     */
    public LambdaQueryWrapperX<T> ltIfPresent(SFunction<T,?> field, Object value){
        if (ObjectUtil.isNotEmpty(value)){
            return (LambdaQueryWrapperX<T>) super.le(field,value);
        }
        return  this;
    }

    /**
     * 大于等于
     * @param field
     * @param value
     * @return
     */
    public LambdaQueryWrapperX<T> geIfPresent(SFunction<T,?> field, Object value){
        if (ObjectUtil.isNotEmpty(value)){
            return (LambdaQueryWrapperX<T>) super.ge(field,value);
        }
        return  this;
    }

    /**
     * 相等
     * @param field
     * @param value
     * @return
     */
    public LambdaQueryWrapperX<T>likeIfPresent(SFunction<T,?> field, Object value){
        if(ObjectUtil.isNotEmpty(value)){
            return (LambdaQueryWrapperX<T>) super.like(field,value) ;
        }
        return this;
    }

}
